﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeamWork_Server
{
    public static class CommandsFactory
    {
        public static Dictionary<string, object> Variables = new Dictionary<string, object>();
        public static Dictionary<string, bool> ServiceStats = new Dictionary<string, bool>();

        public static void Initialize()
        {
            //Variables...
            Variables.Add("net_external_ip", null); // This gets assigned on the server startup

            Variables.Add("admin_master_key", "NULL"); // Format: 

            Variables.Add("admin_coder_key", "NULL"); // Format: 32-bit Alphanumeric Value

            Variables.Add("admin_rcon_password", 12345); // 12345 is the default value, range may be from 5 to 30 characters

            Variables.Add("admin_password", "12345_admin"); // 12345_admin is the default value, range is unlimited and can be any kind of string

            Variables.Add("admin_rcon_allow_external", false); // FALSE = Don't allow connections from external points, otherwise TRUE

            Variables.Add("admin_project_status", ""); // Represents the project status, value may be any kind of string

            Variables.Add("http_allow_file_download", true); // TRUE = Users can download the project files, otherwise FALSE. (NOTE: This doesn't take effect for the coders)

            //Service Stats
            // TRUE = Online, FALSE = Offline
            ServiceStats.Add("HTTP", true);

            ServiceStats.Add("Chat", true);

            ServiceStats.Add("Subscription", true);
        }

        public static bool ExecuteSetCommand(string variable, object value)
        {
            try
            {
                Variables[variable] = value;
                Log.Info("Variable '" + variable + "' has been set to '" + value.ToString() + "'.");
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool ExecuteStatusCommand(string service, bool status)
        {
            try
            {
                ServiceStats[service] = status;
                Log.Info(service + " status has been set to " + status.ToString());
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
